<template >
  <div>
    <div class="title">
      <button @click="flag=true"
              :class="flag?'active':''">列表</button>
      <button :class="!flag?'active':''"
              @click="flag=false">图标</button>
    </div>
    <div class="
              list"
         v-if="flag">
      <div class="list_one"
           v-for="item in articles"
           :key="item">
        <img :src="item.image.small"
             alt="">
        <span>{{item.title}}</span>
      </div>
    </div>
    <!-- 图表 -->
    <div class="icon"
         v-if="!flag">
      <img :src="item.image.large"
           v-for="(item,index) in articles"
           :key="index">
    </div>
  </div>
</template>
<script>
export default {
  name: "layout",
  data () {
    return {
      flag: true,
      articles: [{
        "title": "HTML 教程",
        "url": "https://www.runoob.com/html/html-tutorial.html",
        "image": {
          "large": "https://static.runoob.com/images/mix/htmlbig.png",
          "small": "https://static.runoob.com/images/icon/html.png"
        }
      },
      {
        "title": "CSS 教程",
        "url": "https://www.runoob.com/css/css-tutorial.html",
        "image": {
          "large": "https://static.runoob.com/images/mix/cssbig.png",
          "small": "https://static.runoob.com/images/icon/css.png"
        }
      },
      {
        "title": "JS 教程",
        "url": "https://www.runoob.com/js/js-tutorial.html",
        "image": {
          "large": "https://static.runoob.com/images/mix/jsbig.jpeg",
          "small": "https://static.runoob.com/images/icon/js.png"
        }
      },
      {
        "title": "SQL  教程",
        "url": "https://www.runoob.com/sql/sql-tutorial.html",
        "image": {
          "large": "https://static.runoob.com/images/mix/sqlbig.png",
          "small": "https://static.runoob.com/images/icon/sql.png"
        }
      },
      {
        "title": "Ajax 教程",
        "url": "https://www.runoob.com/ajax/ajax-tutorial.html",
        "image": {
          "large": "https://static.runoob.com/images/mix/ajaxbig.png",
          "small": "https://static.runoob.com/images/icon/ajax.png"
        }
      },
      {
        "title": "Python 教程",
        "url": "https://www.runoob.com/python/python-tutorial.html",
        "image": {
          "large": "https://static.runoob.com/images/mix/pythonbig.png",
          "small": "https://static.runoob.com/images/icon/python.png"
        }
      }]
    }
  }
}
</script>
<style  scoped lang="less">
.title {
  width: 600px;
  margin: 0 auto;
  height: 40px;
  background: skyblue;
  display: flex;
  justify-content: flex-end;
  button {
    margin-right: 20px;
  }
  .active {
    color: red;
  }
}
.list {
  width: 600px;
  margin: 0 auto;
  .list_one {
    height: 120px;
    background: slateblue;
    margin-top: 10px;
    display: flex;
    align-items: center;
    img {
      width: 100px;
      height: 100px;
      margin: 0 30px;
    }
  }
}
.icon {
  width: 600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  img {
    width: 250px;
    height: 250px;
  }
}
</style>